/*
* PROJECT: Happy New Year
* VERSION: 1.0
* AUTHOR: Mattias Thell
* URL: http://www.mattiasthell.com
*
* */

#include "StringMapManager.hpp"

namespace aur {

	/*
	template <class T>
	StringMapManager<T>* StringMapManager<T>::mInstance = 0;
	*/

	template <class T>
	StringMapManager<T>::StringMapManager()
	{
	}

	template <class T>
	StringMapManager<T>::~StringMapManager()
	{
	}

	/*
	template <class T>
	StringMapManager<T>* StringMapManager<T>::GetInstance()
	{
		if(mInstance == 0) {
			mInstance = new StringMapManager();
		}

		return mInstance;
	}

	template <class T>
	void StringMapManager<T>::Destroy()
	{
		if(mInstance != 0)
		{
			delete mInstance;
			mInstance = 0;
		}
	}
	*/

	template <class T>
	bool StringMapManager<T>::Add(const std::string name, T t)
	{
		if(mMap.find(name) != mMap.end())
			return false;

		mMap.insert(TMapPair(name, t));

		return true;
	}

	template <class T>
	T StringMapManager<T>::Get(const std::string name)
	{
		TMap::iterator it = mMap.find(name);
		if(it == mMap.end()) {
			throw std::logic_error; // Should probably do something more useful here...
		}

		return it->second;
	}
}